class Admin::AttributesController < Admin::BaseController
 
  def index
    @attributes = Attribute.all
  end

  
  def new
    @attribute = Attribute.new
  end


  def edit
    @attribute = Attribute.find(params[:id])
  end


  def create
    @attribute = Attribute.new(params[:attribute])

    if @attribute.save
      flash[:notice] = 'Attribuut is aangemaakt.'
      redirect_to admin_attributes_path
    else
      render :action => "new"
    end
  end


  def update
    @attribute = Attribute.find(params[:id])

    if @attribute.update_attributes(params[:attribute])
      flash[:notice] = 'Attribuut is aangepast.'
      redirect_to admin_attributes_path
    else
      Rails.logger.debug @attribute.update_attributes(params[:attribute]).inspect
      Rails.logger.debug @attribute.valid?.inspect
      render :action => "edit"
    end
  end


  def destroy
    @attribute = Attribute.find(params[:id])
    @attribute.destroy

    flash[:notice] = 'Het attribuut is verwijderd.'

    redirect_to admin_attributes_path
  end
end
